package com.cac.demo.service.palletCodeQuery;

import com.cac.demo.dao.palletCodeQuery.PalletCodeQueryDao;
import com.cac.demo.util.adapter.DaoException;
import com.cac.demo.util.adapter.QueryReqBean;
import com.cac.demo.util.adapter.QueryRespBean;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
public class PalletCodeQueryService {
    @Autowired
    private PalletCodeQueryDao palletCodeQueryDao;

    @Transactional
    /*托盘信息查询*/
    public QueryRespBean<HashMap> palletCodeQuery(QueryReqBean<HashMap> queryReqBean, String orderBy, String Keywords){
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try{
            PageHelper.startPage(queryReqBean.getPageParameter());
            HashMap searchParams = queryReqBean.getSearchParams();
            Page<HashMap> dataList = palletCodeQueryDao.palletCodeQuery(searchParams,orderBy,Keywords);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        }catch (Exception e){
            throw  new DaoException(e.getMessage(),e);
        }
    }
    @Transactional
    /*判断托盘信息是否为空*/
    public List<HashMap> palletCodeQuery(HashMap searchParams, String Keywords){
        try{
            List<HashMap> dataList = palletCodeQueryDao.palletCodeQuery(searchParams,Keywords);
            return dataList;
        }catch (Exception e){
            throw  new DaoException(e.getMessage(),e);
        }
    }
}
